<!DOCTYPE html>
<!-- saved from url=(0042)https://jishuin.proginn.com/p/763bfbd31896 -->
<html lang="zh" class=" "><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    

    <title>
        老半天，终于把 redis 持久化搞懂了-技术圈
    </title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="Cache-Control" content="no-transform">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <meta name="keywords" content="老半天，终于把 redis 持久化搞懂了">
    <meta name="author" content="苦逼的码农">
    <meta name="description" content="作者|莱乌作为内存数据库，Redis 在数据存储与读取上的速度是毫不逊色的，这点毋庸置疑。但是对于内存来说，断电或遇到故障后数据就会丢失，这却是一个">
        <meta name="mobile-agent" content="format=html5;url=https://jishuin.proginn.com/p/763bfbd31896">
        <meta name="_token" content="0MwyosIvcZYoNrVlNK0PGhnQRVmyzXPbihAgG05M">
            <meta name="applicable-device" content="pc,mobile">
                <link rel="canonical" href="https://jishuin.proginn.com/p/763bfbd31896">
        <link rel="stylesheet" href="./老半天，终于把 redis 持久化搞懂了-技术圈_files/semantic.css">
    <link rel="stylesheet" href="./老半天，终于把 redis 持久化搞懂了-技术圈_files/styles.css">
    <link rel="stylesheet" href="./老半天，终于把 redis 持久化搞懂了-技术圈_files/inn.css">
    <link rel="stylesheet" href="./老半天，终于把 redis 持久化搞懂了-技术圈_files/top.css">
    <link rel="stylesheet" href="./老半天，终于把 redis 持久化搞懂了-技术圈_files/proginn.css">
    <link rel="stylesheet" href="./老半天，终于把 redis 持久化搞懂了-技术圈_files/social_share.css">
    <link rel="shortcut icon" href="https://stacdn.proginn.com/favicon_new.ico">
    <link rel="stylesheet" href="./老半天，终于把 redis 持久化搞懂了-技术圈_files/search.css">
    <link rel="stylesheet" href="./老半天，终于把 redis 持久化搞懂了-技术圈_files/new.css">
    <script src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/f.txt"></script><script src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/f(1).txt" id="google_shimpl"></script><script src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/push.js.下载"></script><script src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/hm.js.下载"></script><script type="text/javascript">var baseUrl = "/";</script>
    <script src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/scripts.js.下载"></script>
    <script data-ad-client="ca-pub-5000516321900143" async="" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/f(2).txt" data-checked-head="true"></script>
    <script>
		Config = {
			'cdnDomain': '/',
			'user_id': 0,
			'routes': {
				'notificationsCount': 'https://jishuin.proginn.com/notifications/count',
				'upload_image': 'https://jishuin.proginn.com/api/upload_image'
			},
			'token': '0MwyosIvcZYoNrVlNK0PGhnQRVmyzXPbihAgG05M',
			'following_users': [],
		};
		window.csrf = '0MwyosIvcZYoNrVlNK0PGhnQRVmyzXPbihAgG05M';
		var ShowCrxHint = 'no';
    </script>

    
<meta http-equiv="origin-trial" content="AxujKG9INjsZ8/gUq8+dTruNvk7RjZQ1oFhhgQbcTJKDnZfbzSTE81wvC2Hzaf3TW4avA76LTZEMdiedF1vIbA4AAABueyJvcmlnaW4iOiJodHRwczovL2ltYXNkay5nb29nbGVhcGlzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzVGhpcmRQYXJ0eSI6dHJ1ZX0="><meta http-equiv="origin-trial" content="Azuce85ORtSnWe1MZDTv68qpaW3iHyfL9YbLRy0cwcCZwVnePnOmkUJlG8HGikmOwhZU22dElCcfrfX2HhrBPAkAAAB7eyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A16nvcdeoOAqrJcmjLRpl1I6f3McDD8EfofAYTt/P/H4/AWwB99nxiPp6kA0fXoiZav908Z8etuL16laFPUdfQsAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="AxBHdr0J44vFBQtZUqX9sjiqf5yWZ/OcHRcRMN3H9TH+t90V/j3ENW6C8+igBZFXMJ7G3Pr8Dd13632aLng42wgAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2NTI3NzQ0MDAsImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A88BWHFjcawUfKU3lIejLoryXoyjooBXLgWmGh+hNcqMK44cugvsI5YZbNarYvi3roc1fYbHA1AVbhAtuHZflgEAAAB2eyJvcmlnaW4iOiJodHRwczovL2dvb2dsZS5jb206NDQzIiwiZmVhdHVyZSI6IlRydXN0VG9rZW5zIiwiZXhwaXJ5IjoxNjUyNzc0NDAwLCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><meta http-equiv="origin-trial" content="A/OOU4XAFfeAV4kM4+W9WBwNAHqq/bvtrRcJ1wpnNyO/i076BSUy1d14l2kBEgVmEuvxojSpD23172C6hBg2AQYAAACWeyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjM0MDgzMTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="AwrB+XVH/KV6HfZNVtSEqlUJi3yUbtCp0/TJRj+38NDIw19/9P1h7ECTtdLdhIzG0Bsl4n/0rVmttJtGUCcewgAAAACceyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjM0MDgzMTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><meta http-equiv="origin-trial" content="Ax15QOERqai2A5XWrDY38Eg07xh2T0pkhpDPJuDlxr7D2Ka8wHvklgK7tTPZOnT+8H31lwHto5JpvYV8jRn1WgIAAACceyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjM0MDgzMTk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlLCJ1c2FnZSI6InN1YnNldCJ9"><link rel="preload" href="./老半天，终于把 redis 持久化搞懂了-技术圈_files/f(3).txt" as="script"><script type="text/javascript" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/f(3).txt"></script></head>
<body class="proginn" id="body">

<div id="wrap">

    <!-- <div style="height: 30px;line-height: 30px;font-size: 14px;text-align: center;">
</div> -->
<div class="header top-menu" id="top-menu">
    <!-- <div style="height: 30px;line-height: 30px;background-color: #FFFFCC;font-size: 14px;text-align: center;">
        【公告】因域名备案需要，站点域名将临时变更为“gitinn.com”,11月10日起原域名“proginn.com”暂停访问，预计为期1个月。如有不便，敬请谅解。<a href="https://www.gitinn.com/community/topics/3376">查看详情></a>
        【公告】程序员客栈 2019年春节期间服务安排通知（1月31日-2月11日）<a href="https://www.proginn.com/community/topics/3524">查看详情></a>
    </div> -->
    <div class="menu-container ui inverted menu i_header">
        <a href="https://jishuin.proginn.com/" class="item logo"></a>
        <a href="https://www.proginn.com/" class="item page">首页</a>
        <a href="https://www.proginn.com/cat/" class="item page">程序员</a>

        <style>
            #top-menu .menu-container .top-search .input{
                width: 234px;
            }
        </style>

        <div class=" item page dropDownArea" data-v-b86c55f0="">
            <div type="button" class="item tec myButton" data-v-b86c55f0="" data-index="1">工作</div>
            <div type="button" class="myButton dev display-none" style="margin-left: 20px;" data-v-b86c55f0="" data-index="2">服务</div>
            <div class="showDropDownArea" data-v-b86c55f0="">
                <div class="contentArea" data-v-b86c55f0="">
                    <div class="leftSelect" data-v-b86c55f0="">
                        <div class="downCell downCell1 choosed" data-v-b86c55f0="" data-index="1">
                            <div class="cnName" data-v-b86c55f0="">工作</div>
                            <div class="enName" data-v-b86c55f0="">Freelance</div>
                        </div>
                        <div class="downCell downCell2" data-v-b86c55f0="" data-index="2">
                            <div class="cnName" data-v-b86c55f0="">服务</div>
                            <div class="enName" data-v-b86c55f0="">Service</div>
                        </div>
                        <!-- <div class="downCell downCell2" data-v-b86c55f0=""  data-index="2">
                            <div class="cnName" data-v-b86c55f0="">开发</div>
                            <div class="enName" data-v-b86c55f0="">Industry Solutions</div>
                        </div> -->
                        <!-- <div class="downCell downCell3" data-v-b86c55f0="" data-index="3">
                            <div class="cnName" data-v-b86c55f0="">招聘</div>
                            <div class="enName" data-v-b86c55f0="">Technical recruitment</div>
                        </div> -->
                    </div>
                    <div class="rightShow" data-v-b86c55f0="">
                        <div class="rightBigCell rightIndex1 ok " data-v-b86c55f0="" data-index="1">
                            <a class="smallCell" data-v-b86c55f0="" href="https://www.proginn.com/cloud?from=top_nav">
                                <div class="cellLeftIcon" data-v-b86c55f0="">
                                    <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/job@2x.png" alt="" data-v-b86c55f0=""></div>
                                <div class="cellRightArea" data-v-b86c55f0="">
                                    <div class="cellRightName" data-v-b86c55f0="">自由工作</div>
                                    <div class="cellRightDesc" data-v-b86c55f0="">远程工作、驻场工作</div>
                                </div>
                            </a>
                            <a class="smallCell" data-v-b86c55f0="" href="https://jishuin.proginn.com/type/service?from=index">
                                <div class="cellLeftIcon" data-v-b86c55f0="">
                                    <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/kaifain@2x.png" alt="" data-v-b86c55f0="">
                                </div>
                                <div class="cellRightArea" data-v-b86c55f0="">
                                    <div class="cellRightName" data-v-b86c55f0="">项目开发</div>
                                    <div class="cellRightDesc" data-v-b86c55f0="">一站式软件开发</div>
                                </div>
                            </a>
                        </div>
                        <div class="rightBigCell rightIndex1 ok" data-v-b86c55f0="" data-index="2">
                            <a class="smallCell" data-v-b86c55f0="" href="https://www.proginn.com/outsource/sitePublicity?from=top_nav">
                                <div class="cellLeftIcon" data-v-b86c55f0="">
                                    <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/project@2x.png" alt="" data-v-b86c55f0="">
                                </div>
                                <div class="cellRightArea" data-v-b86c55f0="">
                                    <div class="cellRightName" data-v-b86c55f0="">人力外包</div>
                                    <div class="cellRightDesc" data-v-b86c55f0="">高效技术人力灵活用工</div>
                                </div>
                            </a>
                            <!-- <a class="smallCell" data-v-b86c55f0="" href="https://job.proginn.com/?from=top_nav">
                                <div class="cellLeftIcon" data-v-b86c55f0="">
                                    <img src="https://stacdn.proginn.com/image/header/new/cloud@2x.png" alt=""
                                        data-v-b86c55f0=""></div>
                                <div class="cellRightArea" data-v-b86c55f0="">
                                    <div class="cellRightName" data-v-b86c55f0="">任务大厅</div>
                                    <div class="cellRightDesc" data-v-b86c55f0="">专注程序员技术招聘</div>
                                </div>
                            </a> -->
                        </div>
                        <!-- 更多：资源商城、技能列表、咨询列表 -->
                        <div class="rightBigCell rightIndex2" data-v-b86c55f0="" data-index="2">
                            <a class="smallCell" data-v-b86c55f0="" href="https://www.proginn.com/works/?from=top_nav">
                                <div class="cellLeftIcon" data-v-b86c55f0="">
                                    <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/work_down@2x.png" alt="" data-v-b86c55f0="">
                                </div>
                                <div class="cellRightArea" data-v-b86c55f0="">
                                    <div class="cellRightName" data-v-b86c55f0="">资源商城</div>
                                    <div class="cellRightDesc" data-v-b86c55f0="">各种源码资源任您挑选</div>
                                </div>
                            </a>
                            <a class="smallCell" data-v-b86c55f0="" href="https://www.proginn.com/skill/?from=top_nav">
                                <div class="cellLeftIcon" data-v-b86c55f0="">
                                    <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/skill@2x.png" alt="" data-v-b86c55f0="">
                                </div>
                                <div class="cellRightArea" data-v-b86c55f0="">
                                    <div class="cellRightName" data-v-b86c55f0="">技能服务</div>
                                    <div class="cellRightDesc" data-v-b86c55f0="">高端技术为您提供技能服务</div>
                                </div>
                            </a>
                        </div>
                        <div class="rightBigCell rightIndex2" data-v-b86c55f0="" data-index="2">
                            <a class="smallCell" data-v-b86c55f0="" href="https://www.proginn.com/consult/?from=top_nav">
                                <div class="cellLeftIcon" data-v-b86c55f0="">
                                    <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/consult@2x.png" alt="" data-v-b86c55f0="">
                                </div>
                                <div class="cellRightArea" data-v-b86c55f0="">
                                    <div class="cellRightName" data-v-b86c55f0="">咨询服务</div>
                                    <div class="cellRightDesc" data-v-b86c55f0="">技术专家面对面咨询</div>
                                </div>
                            </a>
                        </div>
                        <!-- <div class="rightBigCell rightIndex3" data-v-b86c55f0="" data-index="3"> -->
                            <!-- <a class="smallCell" data-v-b86c55f0="" href="https://job.proginn.com/?from=top_nav">
                                <div class="cellLeftIcon" data-v-b86c55f0="">
                                    <img src="https://stacdn.proginn.com/image/header/new/cloud@2x.png" alt=""
                                        data-v-b86c55f0=""></div>
                                <div class="cellRightArea" data-v-b86c55f0="">
                                    <div class="cellRightName" data-v-b86c55f0="">飞码招聘</div>
                                    <div class="cellRightDesc" data-v-b86c55f0="">专注程序员技术招聘</div>
                                </div>
                            </a> -->
                            <!-- <a class="smallCell" data-v-b86c55f0="" href="https://www.kaifain.com/">
                                <div class="cellLeftIcon" data-v-b86c55f0="">
                                    <img src="https://stacdn.proginn.com/image/header/new/kaifain2@2x.png" alt=""
                                         data-v-b86c55f0=""></div>
                                <div class="cellRightArea" data-v-b86c55f0="">
                                    <div class="cellRightName" data-v-b86c55f0="">开发屋</div>
                                    <div class="cellRightDesc" data-v-b86c55f0="">数据API交易平台</div>
                                </div>
                            </a>
                            <a class="smallCell" data-v-b86c55f0="" href="https://jishuin.proginn.com/?from=top_nav">
                                <div class="cellLeftIcon" data-v-b86c55f0="">
                                    <img src="https://stacdn.proginn.com/image/header/new/jishuin@2x.png" alt=""
                                         data-v-b86c55f0=""></div>
                                <div class="cellRightArea" data-v-b86c55f0="">
                                    <div class="cellRightName" data-v-b86c55f0="">技术圈</div>
                                    <div class="cellRightDesc" data-v-b86c55f0="">最新行业动态</div>
                                </div>
                            </a>
                        </div>
                        <div class="rightBigCell rightIndex3" data-v-b86c55f0="" data-index="3">
                            <a class="smallCell" data-v-b86c55f0="" href="https://www.yesdev.cn/">
                                <div class="cellLeftIcon" data-v-b86c55f0="">
                                    <img src="https://stacdn.proginn.com/image/header/new/yesdev@2x.png" alt=""
                                         data-v-b86c55f0=""></div>
                                <div class="cellRightArea" data-v-b86c55f0="">
                                    <div class="cellRightName" data-v-b86c55f0="">YesDev</div>
                                    <div class="cellRightDesc" data-v-b86c55f0="">专注软件开发过程中的每一个环节</div>
                                </div>
                            </a>
                            <a class="smallCell" data-v-b86c55f0="" href="https://unisms.apistd.com/?source=pi.pc.nav" target="_blank">
                                <div class="cellLeftIcon" data-v-b86c55f0="">
                                    <img src="https://uni-cdn.oss-cn-hangzhou.aliyuncs.com/public/img/unisms-icon.png" alt="UniSMS (合一短信)" data-v-b86c55f0=""></div>
                                <div class="cellRightArea" data-v-b86c55f0="">
                                    <div class="cellRightName" data-v-b86c55f0="">UniSMS (合一短信)</div>
                                    <div class="cellRightDesc" data-v-b86c55f0="">高可用聚合短信平台</div>
                                </div>
                            </a> -->
                        <!-- </div> -->
                    </div>
                </div>
            </div>
        </div>

        <div class="item top-search" data-widget="top-search">
            <div class="ui transparent icon input">
                <form action="https://jishuin.proginn.com/user/searchTopic" method="GET">
                    <input type="text" autocomplete="off" value="" name="keyword" placeholder="搜索您感兴趣的文章">
                </form>
                <i class="search link icon"></i>
            </div>
            <div class="dropdownNew" style="display: none" tabindex="-1"></div>
        <div class="dropdownNew" style="display:none;"><div class="searchAns"></div></div></div>

        <!-- 更多 -->
        <div class="item-more menu">
            <div class="item item-more">
                <div class="ui dropdown left top pointing dropdown-more" style="position: relative;" tabindex="0">
                    <div>更多</div>
                    <div class="menu more-content" tabindex="-1">
                        <a class="more-item item" href="https://www.kaifain.com/">
                            <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/kaifain2@2x.png" alt="">
                            <span>开发屋</span>
                        </a>
                        <a class="more-item item" href="https://jishuin.proginn.com/?from=top_nav">
                            <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/jishuin@2x.png" alt="">
                            <span>技术圈</span>
                        </a>
                        <a class="more-item item" href="https://unisms.apistd.com/?source=pi.pc.nav" target="_blank">
                            <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/unisms-icon.png" alt="">
                            <span>UniSMS (合一短信)</span>
                        </a>
                        <a class="more-item item" href="https://www.yesdev.cn/" target="_blank">
                            <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/yesdev@2x.png" alt="">
                            <span>YesDev</span>
                        </a>
                    </div>
                </div>
            </div>
        </div>

                                <div class="right menu">
                <a href="https://www.proginn.com/index/app" class="item">APP下载</a>
                <a href="javascript:;" rel="nofollow" class="item login ajax_login_btn">登录</a>
                <a href="https://www.proginn.com/user/register" class="item">注册</a>
            </div>
            </div>
</div>

    <div class="container">

        
            <style>
        .topic.panel {
            border: none;
        }

        .Breadcrumbs{
            color:#666666;
            font-size: 12px;
            width: 1000px;
            padding:0px;
            margin: 10px  auto  ;
        }
        div.status_info{
          display: flex;
          align-items: center;
            margin: 15px auto 10px auto;
            font-size: 12px;
        }
        span.zt_span{
            color:#999999;
            margin:auto 15px auto 5px;
        }
        .topics-show .topic-title{
            font-size: 28px;
            margin-bottom: 13px;
        }
        .baseinfo_div{
            margin-top: 30px;
        }
        .content-body{
            line-height:25px;
        }

        .modal {
            width: 270px;
            height: 50px;
            position: fixed;
            z-index: 11000;
            left: 50%;
            margin-top: 0;
            top: 50%;
            text-align: center;
            border-radius: 13px;
            overflow: hidden;
            opacity: 0;
            -webkit-transform: translate(-50%);
            transform: translate(-50%);
            color: #000;
            display: none;
        }

        .modal.modal-in {
            opacity: 1;
            -webkit-transition-duration: 400ms;
            transition-duration: 400ms;
            -webkit-transform: translate3d(-50%, 0, 0) scale(1);
            transform: translate3d(-50%, 0, 0) scale(1);
        }
        .modal.modal-out {
            opacity: 0;
            z-index: 10999;
            -webkit-transition-duration: 400ms;
            transition-duration: 400ms;
            -webkit-transform: translate3d(-50%, 0, 0) scale(1);
            transform: translate3d(-50%, 0, 0) scale(1);
        }
        .toast {
            padding: 15px;
            border-radius: 5px;
            background-color: rgba(0, 0, 0, 0.7);
            color: #fff;
            text-align: center;
            font-size: 14px;
        }


        .el-breadcrumb {
            font-size: 14px;
            line-height: 1;
            padding: 12px 0;
            margin: -6px 0 6px;
        }

        .el-breadcrumb:after,.el-breadcrumb:before {
            display: table;
            content: ""
        }

        .el-breadcrumb:after {
            clear: both
        }

        .el-breadcrumb__separator {
            margin: 0 4px;
            display: inline-block;
            position: relative;
        }

        .el-breadcrumb__separator::before,
        .el-breadcrumb__separator::after {
            content: '';
            width: 7px;
            height: 1px;
            background: #c0c4cc;
            display: block;
            position: relative;
        }

        .el-breadcrumb__separator::before {
            -webkit-transform: rotate(45deg);
            transform: rotate(45deg);
            top: -5px;
        }

        .el-breadcrumb__separator::after {
            -webkit-transform: rotate(-45deg);
            transform: rotate(-45deg);
            top: -1px;
        }

        .el-breadcrumb__inner {
            color: #606266
        }

        .el-breadcrumb__inner.is-link,.el-breadcrumb__inner a {
            font-weight: 700;
            text-decoration: none;
            transition: color .2s cubic-bezier(.645,.045,.355,1);
            color: #303133
        }

        .el-breadcrumb__inner.is-link:hover,.el-breadcrumb__inner a:hover {
            color: #409eff;
            cursor: pointer
        }

        .el-breadcrumb__item:last-child .el-breadcrumb__inner,.el-breadcrumb__item:last-child .el-breadcrumb__inner:hover,.el-breadcrumb__item:last-child .el-breadcrumb__inner a,.el-breadcrumb__item:last-child .el-breadcrumb__inner a:hover {
            font-weight: 400;
            color: #606266;
            cursor: text
        }

        .el-breadcrumb__item:last-child .el-breadcrumb__separator {
            display: none
        }

    </style>
    <div style="display: none" id="isLogin" data-value="0"></div>

    <div class="el-breadcrumb">
        <span class="el-breadcrumb__item">
            <span class="el-breadcrumb__inner"><a href="https://jishuin.proginn.com/">首页</a></span>
        </span>
        <i class="el-breadcrumb__separator"></i>
        <span class="el-breadcrumb__item">
            <span class="el-breadcrumb__inner">文章详情</span>
        </span>
    </div>

    <div class="col-md-9 topics-show main-col">
        <!-- Topic Detial -->
        <div class="topic panel panel-default">
            <div class="infos panel-heading">

                <h1 id="topic_title" class="panel-title topic-title">老半天，终于把 redis 持久化搞懂了</h1>

                <div class="status_info">
                    <a style="text-decoration: none" href="https://jishuin.proginn.com/u/385691">
                        <img style="border-radius: 50%;" width="20px" height="20px" alt="" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/cps_wx_0173a365895a.jpg!mediumicon">
                        苦逼的码农
                    </a>
                    <span style="color:#D8D8D8;margin:auto 10px;">|</span>
                    <img class="" width="18px" height="15px" alt="" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/BIyHQn5nst.png">
                    <span class="zt_span">490</span>

                    <img class="" width="13px" height="13px" alt="" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/jxqdC7tPN6.png!16X16">
                    <span class="zt_span">
                    2020-11-18 01:30                    </span>

                    <img class="" width="16px" height="16px" alt="" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/49lQfeB7kX.png!16X16">
                    <span class="zt_span">0</span>

                    <img class="" width="16px" height="16px" alt="" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/good-icon.png">
                    <span class="zt_span">0</span>

                    <img class="" width="16px" height="16px" alt="" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/collect-icon.png">
                    <span class="zt_span">0</span>
                </div>

                       
                           </div>

            <div class="content-body entry-content panel-body">

                <div class="markdown-body" id="emojify">
<div class="cps-content rich_media_area_primary"><div class="rich_media_content">
                    

                    

                    
                    
                    <section data-mpa-category="背景" data-mpa-template="t" style="background-image: url(" https:="" mmbiz.qpic.cn="" mmbiz_png="" g6hbz0jzzb2xe57wwgyz5xcbc8rqyprgzpjbmxyojgk5zsvjanicbxn4az2axdksibv3tz7xibib4bmq8iclcitibiw="" 640?wx_fmt="png&quot;);&quot;" data-mpa-powered-by="yiban.io"><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.6734375" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/52fa4ad9404ecf0eb3cf79b05a157180.webp" data-type="image" data-w="1280" style=""><br></p><p><span style="">作者|莱乌</span><br></p><p><span style=""><br></span></p><p><span style="font-size: 15px;">作为内存数据库，Redis 在数据存储与读取上的速度是毫不逊色的，这点毋庸置疑。但是对于内存来说，断电或遇到故障后数据就会丢失，这却是一个无法回避的问题。令人欣慰的是，基于这样的缺点，Redis 也提供了不同的持久化方案。</span></p><p><br></p><p><span style="font-size: 15px;">各位看官请随小莱接着往下看：</span><br></p><p><span style="font-size: 15px;"><br></span></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.6559766763848397" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/494bc1945f3e548067a1b05bafd0b0dd.webp" data-type="image" data-w="2058" style=""></p><p style="text-align: center;"><span style="">- 思维导图 -</span></p><p><br></p><section data-mpa-template="t" mpa-from-tpl="t" style="white-space: normal;"><section mpa-from-tpl="t" style="padding: 1px 5px;font-size: 14px;"><section mpa-from-tpl="t" style="margin-top: 0.3em;margin-bottom: 0.3em;"><section mpa-from-tpl="t" style="padding-top: 2px;padding-right: 5px;padding-left: 5px;border-bottom: 1px solid rgb(95, 170, 255);border-top-style: none;"><section mpa-from-tpl="t"><section mpa-from-tpl="t" style="margin-top: -5px;margin-bottom: 2px;margin-left: 7px;height: 23px;width: 6px;transform: rotate(45deg);display: inline-block;background-color: rgb(33, 33, 34);"><br></section><section mpa-from-tpl="t" style="margin-top: 2px;margin-left: -17px;width: 0px;height: 0px;border-width: 5px 3px 0px;border-style: solid;border-color: rgb(33, 33, 34) transparent transparent;display: inline-block;transform: rotate(45deg);"><br></section></section><section mpa-from-tpl="t" style="margin-top: -34px;margin-left: 15px;"><section mpa-from-tpl="t" style="padding-top: 5px;padding-right: 15px;padding-left: 15px;"><strong><span mpa-is-content="t" style="font-size: 18px;">RDB持久化</span></strong></section></section></section></section></section></section><p style="white-space: normal;"><strong style=""><span style="color: rgb(25, 67, 156);"><br></span></strong></p><p style="white-space: normal;"><span style="font-size: 15px;">对于 Redis 持久化来说，其实就是将存储在内存中的数据写入到磁盘里，只不过写入的方式是有一定策略的。<br></span></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.5753205128205128" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/5eb22d8a5372914a293017bd420855d3.webp" data-type="image" data-w="1248" style=""></p><p style="white-space: normal;"><br></p><p style="white-space: normal;"><span style="font-size: 15px;">那么我们先来看下第一种持久化，首先出场的是 RDB。</span></p><p style="white-space: normal;"><br></p><p style="white-space: normal;"><strong style=""><span style="color: rgb(25, 67, 156);">1、什么是RDB持久化</span></strong><br></p><p style="white-space: normal;"><br></p><p style="white-space: normal;"><span style="font-size: 15px;">英文名称是 Redis DataBase，它还有一个常用的名字：<strong>快照持久化</strong>。所谓快照，在这里指的是某一时刻的内存数据，而持久化则是将这一时刻的数据以二进制形式写入到磁盘里。</span></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.36382536382536385" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/f3df86701984cdb1a0412a7c39643e96.webp" data-type="image" data-w="962" style=""></p><p style="text-align: center;"><br></p><p style="white-space: normal;"><span style="font-size: 17px;"><strong style=""><span style="color: rgb(25, 67, 156);">2、手动触发机制</span></strong></span></p><p style="white-space: normal;"><span style="font-size: 15px;"><strong style=""><span style="color: rgb(25, 67, 156);"><br></span></strong></span></p><p style="white-space: normal;"><span style="font-size: 15px;"><strong>（1）save 命令</strong></span></p><p style="white-space: normal;"><span style="font-size: 15px;"><strong><br></strong></span></p><p style="white-space: normal;"><span style="font-size: 15px;">你可能会问了，那我通过什么样的方式来实现持久化呢？不知道你有没有用过 save 这个命令，在 Redis 里担任的角色是用来手动触发持久化的。也就是说在 Redis 客户端操作 save 命令就可以将内存数据写入到磁盘里。</span></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.541095890410959" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/6ba529885df10026f42f44929cc21f24.webp" data-type="image" data-w="1022" style=""><span style=""></span></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="white-space: normal;"><span style="font-size: 15px;">不过你可千万不要好奇，生产环境要是这么玩儿的话，数据量少还行，数量大的话那估计八成得凉凉。为什么这么说呢？你稍微了解下它的运行原理就知道了。</span></p><p style="white-space: normal;"><br></p><p style="white-space: normal;"><span style="font-size: 15px;">前面的文章中，我们提到了 Redis 处理命令的方式是以单线程形式来进行的。客户端的请求都会放入一个队列里。当执行 save 命令时，如果执行时间很长的话，后面的请求就会被阻塞，客户端发送的所有命令都会被拒绝。</span></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="white-space: normal;"><span style="font-size: 15px;">这种方式生产场景要慎用！</span></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="white-space: normal;"><span style="font-size: 15px;"><strong style="font-size: 15px;white-space: normal;">（2）bgsave 命令</strong></span></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="white-space: normal;"><span style="font-size: 15px;">还有一个 bgsave 命令。与 save 不同的是，执行过程中它并不会阻塞客户端的请求。而是将持久化工作交给子进程来执行，主进程仍负责客户端请求的处理工作。</span></p><p style="white-space: normal;"><span style="font-size: 15px;"></span></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.632213608957795" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/544dd0e4a748e992418ce51c2ed965e1.webp" data-type="image" data-w="1161" style=""><span style=""></span></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="white-space: normal;"><span style="color: rgb(0, 89, 255);font-size: 17px;"><strong><strong style=""><span style="color: rgb(25, 67, 156);">3、自动触发机制</span></strong></strong></span></p><p style="white-space: normal;"><span style="color: rgb(0, 89, 255);font-size: 17px;"><strong><strong style=""><span style="color: rgb(25, 67, 156);"><br></span></strong></strong></span></p><p style="white-space: normal;"><span style="font-size: 15px;">RDB 持久化既可以通过手动触发，也可以通过服务器配置项来定期执行。</span><span style=""><br></span></p><p style="white-space: normal;"><br></p><p style="white-space: normal;"><span style="font-size: 15px;">自动触发通常是 Redis 中配置文件来执行的。有这么个配置你需要了解下：</span></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="white-space: normal;"><span style=""><strong>save m n</strong></span></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="white-space: normal;"><span style="font-size: 15px;">其中 m 代表秒数，n 代表次数，放在一起</span><span style="">表示的是&nbsp;m 秒内发生 n 次<span style="">变化时</span>，会触发 bgsave。</span></p><p style="white-space: normal;"><span style=""><br></span></p><p style="white-space: normal;"><span style="">了解了自动化配置，我们再来看下 Redis 配置文件 redis.conf 中的三个默认配置项：</span></p><p style="white-space: normal;"><span style=""><br></span></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.18958333333333333" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/05841e871ba207d196c7532dcd0e5c99.webp" data-type="image" data-w="960" style=""></p><p style="text-align: left;"><br></p><p style="text-align: left;"><strong style="">save 900 1 </strong><span style="">表示的是时间900秒内，如果 Redis 中数据至少发生一次变化，就会执行 bgsave。后边两个就不用介绍了，一样的原理。</span><br></p><p style="text-align: left;"><span style="font-size: 15px;"><br></span></p><p style="text-align: left;"><span style="font-size: 15px;">看到这三个配置项，不知道你会不会有疑问，这三个到底该执行哪一个？答案是设置多个 save m n 命令时，满足任何一个条件都会触发持久化。<br></span></p><p style="text-align: left;"><br></p><p style="text-align: left;"><strong style="text-align: left;white-space: normal;color: rgb(0, 89, 255);"><strong style=""><span style="font-size: 17px;color: rgb(25, 67, 156);">4、RDB 文件恢复</span></strong></strong></p><p style="text-align: left;"><br></p><p style="text-align: left;"><span style="font-size: 15px;text-align: left;">前面我们提到过了，持久化的目的就是为了解决内存异常导致的数据丢失问题。那么倘若如果真遇到了这样的情况，RDB 文件如何来实现数据恢复呢？</span></p><p style="text-align: left;"><br></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.39691289966923926" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/92b9926be7c7712c9aa77a20dbda5cfd.webp" data-type="image" data-w="907" style=""></p><p style="text-align: left;"><br></p><p style="text-align: left;"><span style="font-size: 15px;">开启自动持久化后，数据会存储到名为 dump.rdb 的文件中。当 Redis 服务器重启时，检测到&nbsp;<span style="text-align: left;">dump.rdb</span> 文件后，会自动加载进行数据恢复。</span></p><p style="text-align: left;"><br></p><section data-mpa-template="t" mpa-from-tpl="t" style="white-space: normal;"><section mpa-from-tpl="t" style="padding: 1px 5px;font-size: 14px;"><section mpa-from-tpl="t" style="margin-top: 0.3em;margin-bottom: 0.3em;"><section mpa-from-tpl="t" style="padding-top: 2px;padding-right: 5px;padding-left: 5px;border-bottom: 1px solid rgb(95, 170, 255);border-top-style: none;"><section mpa-from-tpl="t"><section mpa-from-tpl="t" style="margin-top: -5px;margin-bottom: 2px;margin-left: 7px;height: 23px;width: 6px;transform: rotate(45deg);display: inline-block;background-color: rgb(33, 33, 34);"><br></section><section mpa-from-tpl="t" style="margin-top: 2px;margin-left: -17px;width: 0px;height: 0px;border-width: 5px 3px 0px;border-style: solid;border-color: rgb(33, 33, 34) transparent transparent;display: inline-block;transform: rotate(45deg);"><br></section></section><section mpa-from-tpl="t" style="margin-top: -34px;margin-left: 15px;"><section mpa-from-tpl="t" style="padding-top: 5px;padding-right: 15px;padding-left: 15px;"><strong><span mpa-is-content="t" style="font-size: 18px;">AOF持久化</span></strong></section></section></section></section></section></section><p style="white-space: normal;"><br></p><p style="white-space: normal;"><span style="font-size: 15px;">介绍完了 RDB 后，我们再来看一种叫作 AOF 的持久化方式。</span></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="white-space: normal;"><span style="font-size: 17px;"><strong style=""><span style="color: rgb(25, 67, 156);">1、什么是AOF持久化</span></strong></span></p><p style="white-space: normal;"><br></p><p style="white-space: normal;"><span style="font-size: 15px;">英文名称是 Append Only File。同样地，它也有一个常用的名字：<strong>文件追加持久化</strong>。与RDB 不同的是，它是通过保存所执行的写命令来实现的，并且保存的数据格式是客户端发送的命令。</span></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.35809018567639256" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/9b07e7b8b0f252489b88907493d3844c.webp" data-type="image" data-w="1131" style=""><span style=""></span></p><p style="text-align: center;"><br></p><p style="white-space: normal;"><span style="font-size: 17px;"><strong style=""><span style="color: rgb(25, 67, 156);">2、AOF&nbsp;实现方式</span></strong></span><br></p><p><br></p><p><span style="font-size: 15px;">想要使用 AOF 持久化方式，需要启用配置文件中的 appendonly 参数。默认情况下，Redis 是不开启的。</span></p><p style="text-align: center;"><br></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.12943632567849686" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/065cdea591cb5c12e72e082dc7c45cac.webp" data-type="image" data-w="958" style=""></p><p><br></p><p><span style="font-size: 15px;">开启 AOF 持久化后每执行一条修改数据的命令，Redis 就会将该命令写入&nbsp;</span><span style="">aof_buf&nbsp;</span><span style="font-size: 15px;">缓冲区。后续写入 AOF 文件中的操作是由下面的配置来控制的：</span></p><p><span style="font-size: 15px;"><br></span></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.22614107883817428" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/66627e1142ad9c7f27d6664aacb64d94.webp" data-type="image" data-w="964" style=""></p><p><br></p><p><span style="font-size: 15px;">这三个配置项分别表示</span></p><p><span style="font-size: 15px;"><br></span></p><p style="text-align: start;"><span style="font-size: 15px;"><strong>appendfsync always</strong>：<span style="color:#000000;font-family:PingFang SC, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="background-color: rgb(255, 255, 255);">每次写入都进行刷盘操作，对性能影响最大，占用磁盘 IO 较高，数据安全性最高。</span></span></span><br></p><p><span style="font-size: 15px;"><br></span></p><p><span style="font-size: 15px;"><strong>appendfsync everysec</strong>：1秒刷一次盘，对性能影响相对较小。</span><span style=""></span></p><p><span style=""><br></span></p><p><span style=""><strong>appendfsync no</strong>：按照操作系统的机制进行刷盘，对性能</span><span style="">影响<span style="background-color: rgb(255, 255, 255);">最小，数据安全性低。</span></span><span style=""></span></p><p><br></p><p><strong style="text-align: left;white-space: normal;color: rgb(0, 89, 255);"><strong style=""><span style="font-size: 17px;color: rgb(25, 67, 156);">3、AOF 重写机制</span></strong></strong></p><p><strong style="text-align: left;white-space: normal;color: rgb(0, 89, 255);"><strong style=""><span style="font-size: 17px;color: rgb(25, 67, 156);"><br></span></strong></strong></p><p><span style="text-align: left;color: rgb(0, 89, 255);"><span style="font-size: 17px;color: rgb(25, 67, 156);"><span style="">随着命令的不断写入，AOF 文件会变得越来越大，这时候该如何是好呢？别急，Redis 中提供了瘦身功能，也就是重写机制。</span></span></span></p><p><span style="text-align: left;color: rgb(0, 89, 255);"><span style="font-size: 17px;color: rgb(25, 67, 156);"><span style=""><br></span></span></span></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.15208333333333332" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/526af609a8ed40a399ef6b4cf887937a.webp" data-type="image" data-w="960" style=""></p><p><span style="text-align: left;color: rgb(0, 89, 255);"><span style="font-size: 17px;color: rgb(25, 67, 156);"><span style=""></span></span></span><br></p><p><span style="text-align: left;color: rgb(0, 89, 255);"><span style="font-size: 17px;color: rgb(25, 67, 156);"><span style="">Redis 配置文件中有两个对应的参数是来决定重写机制的触发时机的。</span></span></span></p><p><span style="text-align: left;color: rgb(0, 89, 255);"><span style="font-size: 17px;color: rgb(25, 67, 156);"><span style=""><br></span></span></span></p><p><span style="text-align: left;color: rgb(0, 89, 255);"><span style="font-size: 17px;color: rgb(25, 67, 156);"><span style=""><strong>auto-aof-rewrite-percentage：</strong><span style="">AOF 文件</span>距离上次文件增长超过多少百分比</span></span></span></p><p><span style="text-align: left;color: rgb(0, 89, 255);"><span style="font-size: 17px;color: rgb(25, 67, 156);"><span style=""><strong>auto-aof-rewrite-min-size：</strong>AOF 文件体积最小多大以上触发</span></span></span></p><p><span style="text-align: left;color: rgb(0, 89, 255);"><span style="font-size: 17px;color: rgb(25, 67, 156);"><span style=""><br></span></span></span></p><p><span style="text-align: left;color: rgb(0, 89, 255);"><span style="font-size: 17px;color: rgb(25, 67, 156);"><span style="">满足所设置的条件时，会自动触发 AOF 重写，此时 Redis 会扫描整个实例的数据，重新生成一个 AOF 文件来达到瘦身的效果。<br></span></span></span></p><p><span style="text-align: left;color: rgb(0, 89, 255);"><span style="font-size: 17px;color: rgb(25, 67, 156);"><span style=""><br></span></span></span></p><p style="white-space: normal;text-align: left;"><strong style="color: rgb(0, 89, 255);"><strong style=""><span style="font-size: 17px;color: rgb(25, 67, 156);">4、AOF 文件恢复</span></strong></strong></p><p style="white-space: normal;text-align: left;"><strong style="color: rgb(0, 89, 255);"><strong style=""><span style="font-size: 17px;color: rgb(25, 67, 156);"><br></span></strong></strong></p><p style="text-align: center;"><img class="rich_pages" data-ratio="1.0401069518716577" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/6f93bdc45aba70c42c1a0b405d1d9257.webp" data-type="image" data-w="748" style=""></p><p style="white-space: normal;text-align: left;"><span style="font-size: 15px;"></span></p><p style="white-space: normal;text-align: left;"><span style="font-size: 15px;">同样地，我们也需要对 AOF 文件进行恢复。和 RBD 不同的是，Redis 中是通过创建一个不带网络连接的伪客户端来进行实现的。为什么要创建伪客户端呢？你想想 AOF 文件中的数据格式，都是由命令组成的。通过客户端直接执行每条命令就可以将数据进行恢复。</span></p><p style="white-space: normal;text-align: left;"><br></p><p style="white-space: normal;text-align: left;"><span style="font-size: 15px;text-align: left;">在这里需要注意的是，如果服务器开启了&nbsp;AOF 持久化功能，会优先使用</span> <span style="font-size: 15px;">AOF 文件来进行恢复。只有在 AOF 关闭状态下，服务器才会使用 RDB 文件来进行还原。</span></p><p style="white-space: normal;text-align: left;"><span style="font-size: 15px;"><br></span></p><p style="white-space: normal;text-align: left;"><span style="font-size: 15px;"><img class="rich_pages" data-ratio="0.8078512396694215" data-s="300,640" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/60dc11f92451b3e3029f8eec91efb8f1.webp" data-type="image" data-w="968" style="text-align: center;white-space: normal;"></span></p><p style="white-space: normal;text-align: left;"><span style="font-size: 15px;"><br></span></p><section data-mpa-template="t" mpa-from-tpl="t" style="white-space: normal;"><section mpa-from-tpl="t" style="padding: 1px 5px;"><section mpa-from-tpl="t" style="margin-top: 0.3em;margin-bottom: 0.3em;"><section mpa-from-tpl="t" style="padding-top: 2px;padding-right: 5px;padding-left: 5px;border-bottom: 1px solid rgb(95, 170, 255);border-top-style: none;"><section mpa-from-tpl="t" style="font-size: 14px;"><section mpa-from-tpl="t" style="margin-top: -5px;margin-bottom: 2px;margin-left: 7px;height: 23px;width: 6px;transform: rotate(45deg);display: inline-block;background-color: rgb(33, 33, 34);"><br></section><section mpa-from-tpl="t" style="margin-top: 2px;margin-left: -17px;width: 0px;height: 0px;border-width: 5px 3px 0px;border-style: solid;border-color: rgb(33, 33, 34) transparent transparent;display: inline-block;transform: rotate(45deg);"><br></section></section><section mpa-from-tpl="t" style="margin-top: -34px;margin-left: 15px;"><section mpa-from-tpl="t" style="padding-top: 5px;padding-right: 15px;padding-left: 15px;"><span style="font-size: 18px;"><strong>两种持久化的优/缺点</strong></span></section></section></section></section></section></section><p style="white-space: normal;"><br></p><p style="white-space: normal;"><span style="font-size: 15px;">到这里，对两种持久化也有了一定的认识，那么我们来看看它们分别有什么优点和缺点：</span></p><p style="white-space: normal;"><br></p><p style="text-align: left;"><strong style="white-space: normal;color: rgb(0, 89, 255);"><strong style=""><span style="font-size: 17px;color: rgb(25, 67, 156);">1、RDB 优点与缺点</span></strong></strong></p><p style="text-align: left;"><strong style="white-space: normal;color: rgb(0, 89, 255);"><strong style=""><span style="font-size: 17px;color: rgb(25, 67, 156);"><br></span></strong></strong></p><p style="text-align: left;"><span style="font-size: 15px;">&nbsp;&nbsp;<strong style="text-align: left;white-space: normal;"><span style="">（1）优点</span></strong></span></p><section style="text-align: left;text-indent: 2em;"><span style="font-size: 15px;text-decoration: underline;">文件体积小</span><span style="font-size: 15px;">：RDB 的文件内容是二进制格式，因此体积比实例内存小。</span></section><section style="text-align: left;text-indent: 2em;"><span style="font-size: 15px;text-decoration: underline;">恢复速度快</span><span style="font-size: 15px;">：当 Redis 实例恢复时，加载 RDB 文件速度很快，能在很短时间内迅速恢复数据。</span></section><p><span style=""><br></span></p><p><span style=""><strong style="font-size: 15px;text-align: left;white-space: normal;"><span style="">&nbsp; （2）缺点</span></strong></span></p><section style="text-indent: 2em;"><span style="font-size: 15px;text-decoration: underline;">数据缺失</span><span style="font-size: 15px;">：RDB 保存的是某一时刻的数据，当 Redis 实例某一时刻异常时，会导致数据丢失。</span></section><section style="text-indent: 2em;"><span style="font-size: 15px;text-decoration: underline;">消耗资源</span><span style="font-size: 15px;">：RDB 文件的生成会消耗大量的 CPU 和内存资源，有一定代价。</span></section><p style="text-align: left;">&nbsp; &nbsp; &nbsp;&nbsp;<br style="white-space: normal;"></p><p style="white-space: normal;"><strong style="color: rgb(0, 89, 255);white-space: normal;"><span style="font-size: 16px;"><strong style="text-align: left;"><strong style=""><span style="font-size: 17px;color: rgb(25, 67, 156);">2、AOF 优点与缺点</span></strong></strong></span></strong></p><p><br></p>&nbsp; &nbsp;<strong style="white-space: normal;font-size: 15px;text-align: left;"><span style="">（1）优点</span></strong><section style="white-space: normal;text-align: left;text-indent: 2em;"><span style="">数据更完整</span><span style="">：AOF 中是及时写入的方式，数据保存更完整。恢复时降低数据的损失率<br></span></section><section style="white-space: normal;text-align: left;text-indent: 2em;"><span style="">易读性强</span><span style="">：AOF 中保存的数据格式是客户端的写入命令，可读性性强。</span></section><p style="white-space: normal;"><span style="font-size: 15px;text-align: left;"><span style=""><br></span></span></p><p style="white-space: normal;"><span style="font-size: 15px;text-align: left;"><span style="">&nbsp; &nbsp;<strong style="white-space: normal;font-size: 15px;text-align: left;"><span style="">（2）缺点</span></strong></span></span></p><section style="white-space: normal;text-align: left;text-indent: 2em;"><span style="">文件体积大</span><span style="">：AOF 中存储客户端所有的写命令，未经压缩，随着命令的写入，文件会越来越大。</span></section><section style="white-space: normal;text-align: left;text-indent: 2em;"><span style="">增加磁盘IO</span><span style="">：AOF 文件刷盘如果采用每秒刷一次的方式会导致磁盘IO升高，影响性能。</span></section><p style="white-space: normal;"><br></p><section data-mpa-template="t" mpa-from-tpl="t" style="white-space: normal;"><section mpa-from-tpl="t" style="padding: 1px 5px;font-size: 14px;"><section mpa-from-tpl="t" style="margin-top: 0.3em;margin-bottom: 0.3em;"><section mpa-from-tpl="t" style="padding-top: 2px;padding-right: 5px;padding-left: 5px;border-bottom: 1px solid rgb(95, 170, 255);border-top-style: none;"><section mpa-from-tpl="t"><section mpa-from-tpl="t" style="margin-top: -5px;margin-bottom: 2px;margin-left: 7px;height: 23px;width: 6px;transform: rotate(45deg);display: inline-block;background-color: rgb(33, 33, 34);"><br></section><section mpa-from-tpl="t" style="margin-top: 2px;margin-left: -17px;width: 0px;height: 0px;border-width: 5px 3px 0px;border-style: solid;border-color: rgb(33, 33, 34) transparent transparent;display: inline-block;transform: rotate(45deg);"><br></section></section><section mpa-from-tpl="t" style="margin-top: -34px;margin-left: 15px;"><section mpa-from-tpl="t" style="padding-top: 5px;padding-right: 15px;padding-left: 15px;"><strong><span mpa-is-content="t" style="font-size: 18px;">混合持久化</span></strong></section></section></section></section></section></section><p style="white-space: normal;"><br></p><p style="white-space: normal;"><span style="font-size: 15px;">既然 RDB 与 AOF 持久化都存在各自的缺点，那么有没有一种更好的持久化方式？</span></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="white-space: normal;"><span style="font-size: 15px;">接下来要介绍的是<strong>混合持久化。</strong>其实就是 RDB 与 AOF 的混合模式，这是 Redis4 之后新增的。</span></p><p style="white-space: normal;"><span style="font-size: 15px;"><span style=""><br></span></span></p><p style="white-space: normal;"><span style="font-size: 15px;"><span style=""><strong style="white-space: normal;color: rgb(0, 89, 255);"><span style="font-size: 16px;"><strong style="text-align: left;"><strong style=""><span style="font-size: 17px;color: rgb(25, 67, 156);">1、持久化方式</span></strong></strong></span></strong></span></span></p><p style="white-space: normal;"><br></p><p style="white-space: normal;"><span style="">混合持久化是通过&nbsp;<span style="">aof-use-rdb-preamble 参数来开启的。</span>它的操作方式是这样的，在写入的时候先把数据以 RDB 的形式写入文件的开头，再将后续的写命令以 AOF 的格式追加到文件中。</span><span style="">这样既能保证数据恢复时的速度，同时又能减少数据丢失的风险。</span><br></p><p style="white-space: normal;"><span style="font-size: 15px;"><br></span></p><p style="white-space: normal;"><span style="font-size: 15px;"><span style=""><strong style="white-space: normal;color: rgb(0, 89, 255);"><span style="font-size: 16px;"><strong style="text-align: left;"><strong style=""><span style="">2、文件恢复</span></strong></strong></span></strong></span></span><br></p><p style="white-space: normal;"><span style="font-size: 15px;"><span style=""><strong style="white-space: normal;color: rgb(0, 89, 255);"><span style="font-size: 16px;"><strong style="text-align: left;"><strong style=""><span style=""><br></span></strong></strong></span></strong></span></span></p><p style="white-space: normal;"><span style="">那么混合持久化中是如何来进行数据恢复的呢？在 Redis 重启时，先加载 RDB 的内容，然后再重放增量 AOF 格式命令。这样就避免了 AOF 持久化时的全量加载，从而使加载速率得到大幅提升。</span></p><p style="white-space: normal;"><br></p><section data-mpa-template="t" mpa-from-tpl="t" style="white-space: normal;"><section mpa-from-tpl="t" style="padding: 1px 5px;font-size: 14px;"><section mpa-from-tpl="t" style="margin-top: 0.3em;margin-bottom: 0.3em;"><section mpa-from-tpl="t" style="padding-top: 2px;padding-right: 5px;padding-left: 5px;border-bottom: 1px solid rgb(95, 170, 255);border-top-style: none;"><section mpa-from-tpl="t"><section mpa-from-tpl="t" style="margin-top: -5px;margin-bottom: 2px;margin-left: 7px;height: 23px;width: 6px;transform: rotate(45deg);display: inline-block;background-color: rgb(33, 33, 34);"><br></section><section mpa-from-tpl="t" style="margin-top: 2px;margin-left: -17px;width: 0px;height: 0px;border-width: 5px 3px 0px;border-style: solid;border-color: rgb(33, 33, 34) transparent transparent;display: inline-block;transform: rotate(45deg);"><br></section></section><section mpa-from-tpl="t" style="margin-top: -34px;margin-left: 15px;"><section mpa-from-tpl="t" style="padding-top: 5px;padding-right: 15px;padding-left: 15px;"><strong><span mpa-is-content="t" style="font-size: 18px;">总结</span></strong></section></section></section></section></section></section><p style="white-space: normal;"><br></p><p style="white-space: normal;"><span style="font-size: 15px;"><strong>RDB持久化</strong></span><br></p><ul class="list-paddingleft-2" style="list-style-type: disc;"><li><p style="white-space: normal;"><span style="font-size: 15px;">将某一时刻的数据以二进制形式写入到磁盘里，服务重启时检测到对应文件自动加载进行数据恢复。</span></p></li><li><p style="white-space: normal;"><span style="font-size: 15px;">有手动触发和自动触发两种机制。</span></p></li></ul><p style="white-space: normal;"><br></p><p style="white-space: normal;"><strong style="font-size: 15px;white-space: normal;">AOF持久化</strong></p><ul class="list-paddingleft-2" style="list-style-type: disc;"><li><p style="white-space: normal;"><span style="font-size: 15px;">以文件追加的方式写入客户端执行的写命令。</span></p></li><li><p style="white-space: normal;"><span style="font-size: 15px;">数据恢复时，通过创建伪客户端的方式执行命令，直到恢复完成。<br></span></p></li></ul><p style="white-space: normal;"><br></p><p style="white-space: normal;"><strong style="white-space: normal;font-size: 15px;">混合持久化</strong></p><ul class="list-paddingleft-2" style="list-style-type: disc;"><li><p style="white-space: normal;"><span style="font-size: 15px;">在写入的时候先把数据以 RDB 的形式写入文件的开头，再将后续的写命令以 AOF 的格式追加到文件中。</span></p></li></ul><p><br></p><section style="color: rgb(0, 0, 0);font-size: 16px;white-space: normal;widows: 1;word-spacing: 2px;caret-color: rgb(255, 0, 0);font-family: Optima-Regular, PingFangTC-light;letter-spacing: 1px;line-height: 2em;text-align: center;"><span style="color: rgb(255, 76, 65);font-size: 20px;"><strong>读者福利</strong></span><br></section><section style="color: rgb(0, 0, 0);font-size: 16px;text-align: left;white-space: normal;widows: 1;word-spacing: 2px;caret-color: rgb(255, 0, 0);font-family: Optima-Regular, PingFangTC-light;letter-spacing: 1px;line-height: 2em;">《程序员内功修炼》第二版强势来袭，汇总了高质量的算法、计算机基础文章<span style="background-color: rgb(255, 255, 255);color: inherit;font-family: -apple-system-font, system-ui, " helvetica="" neue",="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei="" ui",="" yahei",="" arial,="" sans-serif;font-size:="" inherit;"="">并且每一篇文章，要嘛是漫画讲解，要嘛是对话讲解，一步步引导，要嘛</span><span style="background-color: rgb(255, 255, 255);color: inherit;font-family: -apple-system-font, system-ui, " helvetica="" neue",="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei="" ui",="" yahei",="" arial,="" sans-serif;font-size:="" inherit;"="">是图形并茂...</span><span style="color: inherit;font-family: -apple-system-font, system-ui, " helvetica="" neue",="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei="" ui",="" yahei",="" arial,="" sans-serif;font-size:="" inherit;"=""></span></section><p style="margin-top: 1.5em;margin-bottom: 1.5em;color: inherit;font-size: inherit;text-align: left;white-space: normal;widows: 1;word-spacing: 2px;caret-color: rgb(255, 0, 0);background-color: rgb(255, 255, 255);font-family: -apple-system-font, system-ui, " helvetica="" neue",="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei="" ui",="" yahei",="" arial,="" sans-serif;letter-spacing:="" 1px;line-height:="" inherit;"="">文章整体目录</p><figure style="padding-right: 0.5em;padding-left: 0.5em;color: inherit;font-size: inherit;text-align: left;white-space: normal;widows: 1;word-spacing: 2px;caret-color: rgb(255, 0, 0);background-color: rgb(255, 255, 255);font-family: -apple-system-font, system-ui, " helvetica="" neue",="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei="" ui",="" yahei",="" arial,="" sans-serif;letter-spacing:="" 1px;line-height:="" inherit;"=""><img data-ratio="1.0782828282828283" data-type="image" data-w="792" title="" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/fe0b67aa3c241984c285ffb7f408fcef.webp" style="margin-right: auto;margin-left: auto;color: inherit;line-height: inherit;display: block;box-shadow: rgb(210, 210, 210) 0em 0em 0.5em 0px;box-sizing: border-box !important;width: 677px !important;visibility: visible !important;"></figure><p style="margin-bottom: 10px;color: rgb(0, 0, 0);font-size: 16px;text-align: left;white-space: normal;letter-spacing: 2px;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, " pingfang="" sc",="" cambria,="" cochin,="" georgia,="" times,="" "times="" new="" roman",="" serif;"=""><br></p><p style="margin-top: 1.5em;margin-bottom: 1.5em;color: inherit;font-size: inherit;text-align: left;white-space: normal;widows: 1;word-spacing: 2px;caret-color: rgb(255, 0, 0);background-color: rgb(255, 255, 255);font-family: -apple-system-font, system-ui, " helvetica="" neue",="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei="" ui",="" yahei",="" arial,="" sans-serif;letter-spacing:="" 1px;line-height:="" inherit;"=""><strong style="font-size: inherit;line-height: inherit;color: rgb(255, 104, 39);">如何获取</strong></p><p style="margin-top: 1.5em;margin-bottom: 1.5em;color: inherit;font-size: inherit;text-align: left;white-space: normal;widows: 1;word-spacing: 2px;caret-color: rgb(255, 0, 0);background-color: rgb(255, 255, 255);font-family: -apple-system-font, system-ui, " helvetica="" neue",="" "pingfang="" sc",="" "hiragino="" sans="" gb",="" "microsoft="" yahei="" ui",="" yahei",="" arial,="" sans-serif;letter-spacing:="" 1px;line-height:="" inherit;"="">很简单，在我的微信公众号&nbsp;<strong style="font-size: inherit;line-height: inherit;color: rgb(255, 104, 39);">帅地玩编程&nbsp;</strong>回复&nbsp;<strong style="font-size: inherit;line-height: inherit;color: rgb(255, 104, 39);">程序员内功修炼&nbsp;</strong>即可获取《程序员内功修炼》第一版和第二版的 PDF。</p><p style="font-size: 16px;text-align: left;white-space: normal;color: rgb(62, 62, 62);font-family: Consolas, Menlo, Courier, monospace;letter-spacing: 0.544px;widows: 1;word-spacing: 2px;caret-color: rgb(255, 0, 0);">推荐，推荐一个 GitHub，这个 GitHub 整理了几百本常用技术PDF，绝大部分核心的技术书籍都可以在这里找到，GitHub地址：<span style="color: rgb(0, 82, 255);">https://github.com/iamshuaidi/CS-Book</span>（电脑打开体验更好），地址<span style="color: rgb(0, 82, 255);">阅读原文</span>直达</p></section>
                </div></div>
</div>

           
            </div>

            <div class="appends-container" data-lang-append="附言">
                            </div>

            <div class="good-box">
  <div>
    <!-- 如果已赞 -->
    <div class="good " id="good-btn">
      <img class="good-icon" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/good-icon(1).png" alt="good-icon">
      <span class="good-count">0</span>
    </div>
    <!-- 已赞 -->
    <span class="good-zan">赞</span>
  </div>
  <div style="margin-left:57px;">
    <!-- 如果已收藏 -->
    <div class="favorite " id="favorite-btn">
      <img class="favorite-icon" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/collect-icon(1).png" alt="favorite-icon">
      <span class="favorite-count">0</span>
    </div>
    <!-- 已收藏 -->
    <span class="favorite-zan">收藏</span>
  </div>
</div>
<div class="panel-footer operate" style="padding: 30px 15px; display: flex; align-items: center;">
<style>
    .good-box {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
    }
    .good {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width:73px;
      height:73px;
      border-radius: 36px;
      background: #4499FF;
      color: white;
      cursor: pointer;
    }
    .good-death {
      background: #AEAEAE;
      cursor: default;
    }
    .good-icon {
      width: 21px;
      height: auto;
    }
    .good-count {
      margin-top: 4px;
    }
    .good-zan {
      color: #666;
      margin-top: 10px;
      display: block;
      text-align: center;
    }
    .favorite {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width:73px;
      height:73px;
      border-radius: 36px;
      background: #FF9900;
      color: white;
      cursor: pointer;
    }
    .favorite-death {
      background: #AEAEAE;
      cursor: default;
    }
    .favorite-icon {
      width: 21px;
      height: auto;
    }
    .favorite-count {
      margin-top: 4px;
    }
    .favorite-zan {
      color: #666;
      margin-top: 10px;
      display: block;
      text-align: center;
    }
  </style>

  <div class="pull-right" style="text-align: right;width: 100%;">

   
    
    
  </div>
  <div class="clearfix"></div>
</div>


<div class="modal fade" id="exampleModal" tabindex="-1" role="" aria-labelledby="exampleModalLabel">
  <div class="modal-dialog">
    <div class="modal-content">

      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
        <h4 class="modal-title" id="exampleModalLabel">添加附言</h4>
      </div>

     <form method="POST" action="https://jishuin.proginn.com/topics/63638/append" accept-charset="UTF-8">
         <input type="hidden" name="_token" value="0MwyosIvcZYoNrVlNK0PGhnQRVmyzXPbihAgG05M">
        <div class="modal-body">

          <div class="alert alert-warning">
              附加内容, 使用此功能的话, 会给所有参加过讨论的人发送提醒.
          </div>

          <div class="form-group">
              <textarea class="form-control" style="min-height: 20px; overflow: hidden; overflow-wrap: break-word; resize: horizontal; height: 86px;" placeholder="请使用 Markdown 格式书写 ;-)" name="content" cols="50" rows="10"></textarea>
          </div>

          </div>

          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="submit" class="btn btn-primary">提交</button>
          </div>

      </form>

    </div>
  </div>
</div>
        </div>


        <div class="panel panel-default social-share-wrap">
            <div class="panel-body ">
                <div class="social-share-cs social-share share-component"><a class="social-share-icon icon-weibo" target="_blank" href="http://service.weibo.com/share/share.php?url=https%3A%2F%2Fjishuin.proginn.com%2Fp%2F763bfbd31896&amp;title=%E8%80%81%E5%8D%8A%E5%A4%A9%EF%BC%8C%E7%BB%88%E4%BA%8E%E6%8A%8A%20redis%20%E6%8C%81%E4%B9%85%E5%8C%96%E6%90%9E%E6%87%82%E4%BA%86&amp;pic=https%3A%2F%2Finn.proginn.com%2Fuseralbum%2F385691%2Fcps_wx_0173a365895a.jpg!mediumicon&amp;appkey="></a><a class="social-share-icon icon-qq" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https%3A%2F%2Fjishuin.proginn.com%2Fp%2F763bfbd31896&amp;title=%E8%80%81%E5%8D%8A%E5%A4%A9%EF%BC%8C%E7%BB%88%E4%BA%8E%E6%8A%8A%20redis%20%E6%8C%81%E4%B9%85%E5%8C%96%E6%90%9E%E6%87%82%E4%BA%86&amp;source=%E8%80%81%E5%8D%8A%E5%A4%A9%EF%BC%8C%E7%BB%88%E4%BA%8E%E6%8A%8A%20redis%20%E6%8C%81%E4%B9%85%E5%8C%96%E6%90%9E%E6%87%82%E4%BA%86&amp;desc=%E4%BD%9C%E8%80%85%3A%20%E8%8B%A6%E9%80%BC%E7%9A%84%E7%A0%81%E5%86%9C%20%E6%AD%A3%E6%96%87%3A%20%E4%BD%9C%E8%80%85%7C%E8%8E%B1%E4%B9%8C%E4%BD%9C%E4%B8%BA%E5%86%85%E5%AD%98%E6%95%B0%E6%8D%AE%E5%BA%93%EF%BC%8CRedis%20%E5%9C%A8%E6%95%B0%E6%8D%AE%E5%AD%98%E5%82%A8%E4%B8%8E%E8%AF%BB%E5%8F%96%E4%B8%8A%E7%9A%84%E9%80%9F%E5%BA%A6%E6%98%AF%E6%AF%AB%E4%B8%8D%E9%80%8A%E8%89%B2%E7%9A%84%EF%BC%8C%E8%BF%99%E7%82%B9%E6%AF%8B%E5%BA%B8%E7%BD%AE%E7%96%91%E3%80%82%E4%BD%86%E6%98%AF%E5%AF%B9%E4%BA%8E%E5%86%85%E5%AD%98%E6%9D%A5%E8%AF%B4%EF%BC%8C%E6%96%AD%E7%94%B5%E6%88%96%E9%81%87%E5%88%B0%E6%95%85%E9%9A%9C%E5%90%8E%E6%95%B0%E6%8D%AE%E5%B0%B1%E4%BC%9A%E4%B8%A2%E5%A4%B1%EF%BC%8C%E8%BF%99%E5%8D%B4%E6%98%AF%E4%B8%80%E4%B8%AA&amp;pics=https%3A%2F%2Finn.proginn.com%2Fuseralbum%2F385691%2Fcps_wx_0173a365895a.jpg!mediumicon"></a><a class="social-share-icon icon-wechat" target="_blank" href="javascript:"><div class="wechat-qrcode"><h4>微信扫一扫：分享</h4><div class="qrcode" title="https://jishuin.proginn.com/p/763bfbd31896"><canvas width="100" height="100" style="display: none;"></canvas><img alt="Scan me!" src="" style="display: block;"></div><div class="help"><p>微信里点“发现”，扫一下</p><p>二维码便可将本文分享至朋友圈。</p></div></div></a><a class="social-share-icon icon-qzone" target="_blank" href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=https%3A%2F%2Fjishuin.proginn.com%2Fp%2F763bfbd31896&amp;title=%E8%80%81%E5%8D%8A%E5%A4%A9%EF%BC%8C%E7%BB%88%E4%BA%8E%E6%8A%8A%20redis%20%E6%8C%81%E4%B9%85%E5%8C%96%E6%90%9E%E6%87%82%E4%BA%86&amp;desc=%E4%BD%9C%E8%80%85%3A%20%E8%8B%A6%E9%80%BC%E7%9A%84%E7%A0%81%E5%86%9C%20%E6%AD%A3%E6%96%87%3A%20%E4%BD%9C%E8%80%85%7C%E8%8E%B1%E4%B9%8C%E4%BD%9C%E4%B8%BA%E5%86%85%E5%AD%98%E6%95%B0%E6%8D%AE%E5%BA%93%EF%BC%8CRedis%20%E5%9C%A8%E6%95%B0%E6%8D%AE%E5%AD%98%E5%82%A8%E4%B8%8E%E8%AF%BB%E5%8F%96%E4%B8%8A%E7%9A%84%E9%80%9F%E5%BA%A6%E6%98%AF%E6%AF%AB%E4%B8%8D%E9%80%8A%E8%89%B2%E7%9A%84%EF%BC%8C%E8%BF%99%E7%82%B9%E6%AF%8B%E5%BA%B8%E7%BD%AE%E7%96%91%E3%80%82%E4%BD%86%E6%98%AF%E5%AF%B9%E4%BA%8E%E5%86%85%E5%AD%98%E6%9D%A5%E8%AF%B4%EF%BC%8C%E6%96%AD%E7%94%B5%E6%88%96%E9%81%87%E5%88%B0%E6%95%85%E9%9A%9C%E5%90%8E%E6%95%B0%E6%8D%AE%E5%B0%B1%E4%BC%9A%E4%B8%A2%E5%A4%B1%EF%BC%8C%E8%BF%99%E5%8D%B4%E6%98%AF%E4%B8%80%E4%B8%AA&amp;summary=%E4%BD%9C%E8%80%85%3A%20%E8%8B%A6%E9%80%BC%E7%9A%84%E7%A0%81%E5%86%9C%20%E6%AD%A3%E6%96%87%3A%20%E4%BD%9C%E8%80%85%7C%E8%8E%B1%E4%B9%8C%E4%BD%9C%E4%B8%BA%E5%86%85%E5%AD%98%E6%95%B0%E6%8D%AE%E5%BA%93%EF%BC%8CRedis%20%E5%9C%A8%E6%95%B0%E6%8D%AE%E5%AD%98%E5%82%A8%E4%B8%8E%E8%AF%BB%E5%8F%96%E4%B8%8A%E7%9A%84%E9%80%9F%E5%BA%A6%E6%98%AF%E6%AF%AB%E4%B8%8D%E9%80%8A%E8%89%B2%E7%9A%84%EF%BC%8C%E8%BF%99%E7%82%B9%E6%AF%8B%E5%BA%B8%E7%BD%AE%E7%96%91%E3%80%82%E4%BD%86%E6%98%AF%E5%AF%B9%E4%BA%8E%E5%86%85%E5%AD%98%E6%9D%A5%E8%AF%B4%EF%BC%8C%E6%96%AD%E7%94%B5%E6%88%96%E9%81%87%E5%88%B0%E6%95%85%E9%9A%9C%E5%90%8E%E6%95%B0%E6%8D%AE%E5%B0%B1%E4%BC%9A%E4%B8%A2%E5%A4%B1%EF%BC%8C%E8%BF%99%E5%8D%B4%E6%98%AF%E4%B8%80%E4%B8%AA&amp;site=%E8%80%81%E5%8D%8A%E5%A4%A9%EF%BC%8C%E7%BB%88%E4%BA%8E%E6%8A%8A%20redis%20%E6%8C%81%E4%B9%85%E5%8C%96%E6%90%9E%E6%87%82%E4%BA%86"></a></div>
            </div>
        </div>

        <!-- Reply List -->
        <div class="replies panel panel-default list-panel replies-index">
            <div class="panel-heading">
                <div class="total">回复数量: <b>0</b></div>
            </div>

            <div class="panel-body">

                                    <ul class="list-group row"></ul>
                    <div id="replies-empty-block" class="empty-block">暂无评论~~</div>
                                            <!-- Pager -->
                    <div class="pull-right" style="padding-right:20px">
                        
                    </div>
            </div>
        </div>

        <!-- Reply Box -->
        <div class="reply-box form box-block">

            
            <form method="POST" action="https://jishuin.proginn.com/replies" accept-charset="UTF-8" id="reply-form">
                <input type="hidden" name="_token" value="0MwyosIvcZYoNrVlNK0PGhnQRVmyzXPbihAgG05M">
                <input type="hidden" name="topic_id" value="63638">

                <div id="reply_notice" class="box" style="display:none">
    <ul class="helpblock list">
      <li>请注意单词拼写，以及中英文排版，<a href="https://github.com/sparanoid/chinese-copywriting-guidelines">参考此页</a></li>
      <li>支持 Markdown 格式, <strong>**粗体**</strong>、~~删除线~~、<code>`单行代码`</code>, 更多语法请见这里 <a href="https://github.com/riku/Markdown-Syntax-CN/blob/master/syntax.md">Markdown 语法</a></li>
      <li>支持表情，见 <a href="http://www.emoji-cheat-sheet.com/" target="_blank" rel="nofollow">Emoji cheat sheet</a></li>
      <li>@name 会链接到用户页面，并会通知他</li>
      <li>上传图片, 支持拖拽和剪切板黏贴上传, 格式限制 - jp(e)g, png, gif</li>
    </ul>
</div>

                <div class="form-group">
                                            <textarea class="form-control" disabled="disabled" rows="5" placeholder="需要登录后才能发表评论." name="body" cols="50" style="overflow: hidden; overflow-wrap: break-word; resize: horizontal; height: 104px;"></textarea>
                                    </div>

                <div class="form-group status-post-submit">
                    <input class="btn btn-primary disabled" id="reply-create-submit" type="submit" value="回复">
                    <span class="help-inline" title="Or Command + Enter">Ctrl+Enter</span>
                </div>

                <div class="box preview markdown-reply" id="preview-box" style="display:none;"></div>

            </form>
        </div>

    </div>
    <section class="share-panel">
        <a class="contact-btn" href="https://jishuin.proginn.com/index/app">下载APP</a>
    </section>
    <link href="./老半天，终于把 redis 持久化搞懂了-技术圈_files/swiper.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/swiper.min.js.下载"></script>
<div class="col-md-3 side-bar">
    
            <div class="panel panel-default corner-radius" id="coner-radius">
            <div class="side-profile">
                <div class="avatar">
                    <img id="author_avatar" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/cps_wx_0173a365895a.jpg!mediumicon" alt="苦逼的码农">
                    <div class="sex"><i class="fa fa-female"></i></div>
                </div>
                <div class="nickname">
                    <a href="https://jishuin.proginn.com/u/385691" class="header" title="社区等级:1" style="color: #122236" id="author_name">苦逼的码农</a>
                </div>
                <div class="verify">
                                                        </div>
                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                <style>
                    .btn-death {
                        background: #AEAEAE !important;
                    }

                    .counts {
                        display: flex;
                        justify-content: center;
                        align-items: center;
                        margin-top: 40px;
                    }

                    .art-count, .zan-count {
                        display: flex;
                        flex-direction: column;
                        justify-content: center;
                        align-items: center;
                        padding: 4px 27px;
                    }

                    .art-count {
                        border-right: 1px solid rgba(0, 0, 0, .06);
                    }

                    .count {
                        color: #333333;
                        font-family: "DIN Condensed Bold";
                        font-weight: bold;
                        font-size: 25px;
                    }

                    .count-title {
                        font-size: 12px;
                    }
                </style>
                <div class="counts">
                    <div class="art-count">
                        <div class="count">900</div>
                        <div class="count-title">文章</div>
                    </div>
                    <div class="zan-count">
                        <div class="count">7</div>
                        <div class="count-title">获赞</div>
                    </div>
                </div>
                <style>
                    .follow-btn {
                        margin-top: 20px;
                    }
                </style>
                <!-- 如果已关注 -->
                <div class="follow-btn" id="follow-btn">
                    <!-- 已关注 -->
                    <a class="ui blue button view_connect_btn " style="width: 174px;" userid="385691"> 关注TA </a>
                </div>
            </div>
        </div>
    
    <div class="panel panel-default corner-radius" style="position: relative">
        <a href="https://unisms.apistd.com/?source=jsi.pc.sani" title="UniSMS (合一短信) - 高可用聚合短信服务平台" target="_blank">
            <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/unisms-ani-p1.gif" style="width: 66%;display: block;margin: 5px auto 2px;" alt="UniSMS (合一短信)" loading="lazy">
        </a>
        <span style="position: absolute;white-space: nowrap;background: #ff0100;color: #fff;line-height: 1;padding: 1px 2px;font: 9px/1 sans-serif;right: -7px;top: 4px;border-radius: 1px;">NEW</span>
    </div>

                        <div class="panel panel-default corner-radius">
                <div class="panel-heading text-center">
                                        <h3 class="panel-title">该作者其他文章</h3>
                </div>
                <div class="panel-body">
                    <ul class="list">
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd6a884">
                                    LeetCode 232：用栈实现队列
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd6a883">
                                    微信事业群二面：聊聊Cookie、Session、Token背后的故事
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd6a882">
                                    你只管打开，剩下的交给「卧槽」！
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd6a881">
                                    帅地帮十几个人改了简历，不要再犯这种错误了！
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd6a87f">
                                    16:00面试，16:08就出来了 ，问的实在是太...
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd6a87e">
                                    脱单了！
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd6a0c6">
                                    目标是毕业后找工作，学习要有针对性
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd6a0c5">
                                    一个 Java 分布式中间件系统项目实战
                                </a>
                            </li>
                                            </ul>
                </div>
            </div>
                            <div class="panel panel-default corner-radius">
                <div class="panel-heading text-center">
                                        <h3 class="panel-title">相关文章推荐</h3>
                </div>
                <div class="panel-body">
                    <ul class="list">
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd318bf">
                                    太强了，300分钟撸一个基于redis的亿级用户高并发系统
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd31932">
                                    公司用了 6 年的老分布式锁，依然很是牛啊！
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd31a9c">
                                    一步步实现 Redis 搜索引擎
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd3167b">
                                    Redis分片机制
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd31af0">
                                    验证了！300分钟撸一个基于redis的亿级用户高并发系统
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd31bc0">
                                    Redis 数据结构之字符串的那些骚操作
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd31c30">
                                    基于 Redis 配置异步 Celery
                                </a>
                            </li>
                                                    <li>
                                <a href="https://jishuin.proginn.com/p/763bfbd314c0">
                                    虎牙员工被HR抬出公司，网友：能力不行吧，连redis都不会。。。
                                </a>
                            </li>
                                            </ul>
                </div>
            </div>
                            <div style="background: white;padding: 0px 0 0px 0;margin-top: 20px;">
            <div class="home-box swiper-boxs" style="">
                <div class="swiper-container swiper-container-horizontal">
                    <div class="swiper-wrapper" style="transform: translate3d(-560px, 0px, 0px); transition-duration: 300ms;"><div class="swiper-slide swiper-slide-duplicate" data-swiper-slide-index="0" style="width: 250px; margin-right: 30px;">
                                <a rel="nofollow" href="https://unisms.apistd.com/?source=jsi.pc.side">
                                    <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/b608e098e5401feb3dd995dd19342562.jpg" alt="plat-ensure-img">
                                </a>
                            </div>
                                                    <div class="swiper-slide swiper-slide-prev" data-swiper-slide-index="0" style="width: 250px; margin-right: 30px;">
                                <a rel="nofollow" href="https://unisms.apistd.com/?source=jsi.pc.side">
                                    <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/b608e098e5401feb3dd995dd19342562.jpg" alt="plat-ensure-img">
                                </a>
                            </div>
                                            <div class="swiper-slide swiper-slide-duplicate swiper-slide-active" data-swiper-slide-index="0" style="width: 250px; margin-right: 30px;">
                                <a rel="nofollow" href="https://unisms.apistd.com/?source=jsi.pc.side">
                                    <img src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/b608e098e5401feb3dd995dd19342562.jpg" alt="plat-ensure-img">
                                </a>
                            </div></div>
                    <!-- Add Pagination -->
                    <div class="swiper-pagination swiper-pagination-clickable"><span class="swiper-pagination-bullet swiper-pagination-bullet-active"></span></div>
                    <!-- Add Arrows -->

                </div>
                <script>
                    var swiper = new Swiper('.swiper-container', {
                        pagination: '.swiper-pagination',

                        slidesPerView: 1,

                        paginationClickable: true,
                        spaceBetween: 30,
                        autoplay: 3000,
                        autoplayDisableOnInteraction: false,
                        loop: true
                    });
                </script>
            </div>
        </div>

    
    <style>
        .swiper-container {
            width: 100%;
            height: 100%;
            margin-left: auto;
            margin-right: auto;
        }

        .swiper-slide {
            text-align: center;
            font-size: 18px;
            background: #fff;

            /* Center slide text vertically */
            display: -webkit-box;
            display: -ms-flexbox;
            display: -webkit-flex;
            display: flex;
            -webkit-box-pack: center;
            -ms-flex-pack: center;
            -webkit-justify-content: center;
            justify-content: center;
            -webkit-box-align: center;
            -ms-flex-align: center;
            -webkit-align-items: center;
            align-items: center;
        }

        .swiper-boxs {
            width: 250px;
            margin: 0 auto;
            height: 369px
        }

        .swiper-boxs a {
            width: 100%;
            height: 369px
        }

        .swiper-boxs a img {
            width: 100%;
            height: 369px
        }
    </style>
</div>
<div class="clearfix"></div>

    <div class="banner-container rbs row">
    </div>

    </div>

</div>
<div id="footer_dimmer">
    <div class="ui inverted page dimmer">
        <div class="content">
            <div class="center">
                <h3 class="ui icon header" id="customized_footer_dimmer_info">
                    <i class="green checkmark icon"></i>
                </h3>
                <p style="color: rgb(102, 102, 102);">点击空白处退出提示</p>
            </div>
        </div>
    </div>
</div>
<script src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/inn.js.下载"></script>
<script src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/semantic.js.下载"></script>
<script src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/common.js.下载"></script>
<script>
	/**
	 * login
	 */
	$(".ajax_login_btn").on('click', function (e) {
		e.preventDefault();
		var $resumediv = '<div id="resume_div"></div>';
		$("body").after($resumediv);
		$("#resume_div").load('https://www.proginn.com' + "/user/notloginajax");
	});
	$(document).ready(function () {
		window.timer = null;
		$(".dropDownArea .myButton").bind("mouseover", function (e) {
			hideAll()
			var dataIndex = Number(e.target.dataset.index)
			console.log("myButton.....", dataIndex, e)
			// let _class = $("#firstpage");
            // let unSelectColor = _class.css("color");
            switch (dataIndex) {
                case 1:
                    $(".tec").css("color", "#1782d9");
                    $(".dev").css("color", "#515151");
                    break;
                case 2:
                    $(".tec").css("color", "#515151");
                    $(".dev").css("color", "#1782d9");
                    break;
            }
			// 技术人力与开发合并
            if (dataIndex === 1) {
                $('.showDropDownArea .downCell1').addClass('choosed');
                $('.showDropDownArea .rightIndex1').addClass('ok');
            } else {
                $('.showDropDownArea .downCell' + dataIndex).addClass('choosed');
                $('.showDropDownArea .rightIndex' + dataIndex).addClass('ok');
            }
			// if (dataIndex) {
			// 	$('.showDropDownArea .downCell' + dataIndex).addClass('choosed');
			// 	$('.showDropDownArea .rightIndex' + dataIndex).addClass('ok');
			// }
			if (window.timer) {
				clearTimeout(window.timer);
			}
		});

		$(".dropDownArea .downCell").bind("mouseover", function (e) {
			var dataIndex = Number(e.currentTarget.dataset.index)
			console.log("downCell.....", dataIndex, e)
			hideAll()
			if (window.timer) {
				clearTimeout(window.timer);
			}
			if (dataIndex) {
				$('.showDropDownArea .downCell' + dataIndex).addClass('choosed');
				$('.showDropDownArea .rightIndex' + dataIndex).addClass('ok');
			}
		});

		$(".dropDownArea").bind("mouseleave", function () {
			window.timer = setTimeout(function () {
				hideAll();
			}, 300);
		});

		function hideAll() {
			$("div.platform-menu").hide();
			$('.showDropDownArea .downCell').removeClass('choosed');
			$('.showDropDownArea .rightBigCell').removeClass('ok');
            $("div.more-content").hide();
			$('.tec').css('color', '');
            $('.dev').css('color', '');
		}

		$('.dropdown').dropdown({transition: 'drop'});
		$('.i_header .dropdown').dropdown({on: 'hover'});
		$('.solution').dropdown({on: 'hover'});
		$('.message .close').on('click', function () {
			$(this).closest('.message').fadeOut();
		});
		$('.ui.checkbox').checkbox();
		$('.header').popup();
		$('.verify a').popup();
		$('.verify_tag').popup();
		$('.progress').popup();
		$('.popup').popup();
		$(".setting_nav_icon").click(function () {
			$('.setting_nav_icon').transition('tada');
		});
		$(".message_nav_icon").click(function () {
			$('.message_nav_icon').addClass('red').transition('tada');
		});
		$('.basic.test.modal').modal('show');
		$('.menu .item').tab();
	});
	/**
	 * chage online status
	 */
	$('#header_online_status').on("click", function () {
		var valonline = $(this).attr("value");
		$.ajax({
			type: "POST",
			url: baseUrl + "ajax/changeonlinestatus",
			data: "valonline=" + valonline,
			dataType: "json",
			success: function (msg) {
				if (msg.status == 'yes') {
					if (msg.data == 1) {
						$('#header_online_status').attr({value: msg.data, title: msg.info}).addClass('checked');
					} else if (msg.data == 0) {
						$('#header_online_status').attr({value: msg.data, title: msg.info}).removeClass('checked');
					}
				} else {
					alert(msg.info);
				}
			}
		});
	});

</script>


    <script type="text/javascript" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/social_share.js.下载"></script>
    <script type="text/javascript">
        // 关注
        $(".do_quanta_wo").on('click', function(){
            $this = $(this);
            var userid = $this.attr('userid');
            $.ajax({
                type: "POST",
                dataType: "json",
                url: baseUrl + "ajax/quanta",
                data:{uid: userid},
                success:function(response){
                    if (response.status == 'ok') {
                        window.location.reload();
                    } else if (response.status == "login") {
                        var $resumediv = '<div id="resume_div"></div>';
                        $(".main").after($resumediv);
                        $("#resume_div").load('https://www.proginn.com' + "user/notloginajax");
                    } else {
                        $('#customized_footer_dimmer_info').html('<i class="red close icon"></i>' + response.info);
                        $('#footer_dimmer').dimmer('show');
                    }
                }
            });
        });
        // 取消关注
        $(".do_quantacancel_wo").on('click', function(){
            $this = $(this);
            var userid = $this.attr('userid');
            $this.html("处理中...");
            $.ajax({
                type: "POST",
                dataType: "json",
                url: 'https://www.proginn.com' + "ajax/quantacancel",
                data:{uid: userid},
                success:function(msg){
                    if (msg.status == 'ok') {
                        window.location.reload();
                    } else {
                        alert(msg.info);
                        $this.html("已关注");
                    }
                }
            });
        });
    </script>
    <script>
      var followBtn = $('#follow-btn')
      var goodBtn = $('#good-btn')
      var favoriteBtn=$('#favorite-btn');
      followBtn.on('click', doFollow)
      goodBtn.on('click', doLike)
      favoriteBtn.on('click',doFavorite);
      function doFavorite(e) {
          if($('#isLogin')[0].dataset.value === '0') {
              location.href = 'https://www.proginn.com'+'/?loginbox=show'
              return
          }
          $.ajax({
              type: 'POST',
              url: '/api/collection_center/create',
              dataType: "json",
              data: {
	              item_id: '63638',
                  type: 5
              },
              success(res) {
                  console.log(res);
                  if (res.data === "收藏成功"){
	                  toastMsg("收藏成功")
                      $('#favorite-btn').addClass('favorite-death');
                      $('#favorite-btn span').text(parseInt($('#favorite-btn span').text())+1);
                  }else {
	                  toastMsg("取消收藏成功")
	                  $('#favorite-btn').removeClass('favorite-death');
                      $('#favorite-btn span').text(parseInt($('#favorite-btn span').text())-1);
                  }
              },
          })
      }
      var paths = location.pathname.split('/')
      function doFollow(e) {
        e.stopPropagation()
        if($('#isLogin')[0].dataset.value === '0') {
          location.href = 'https://www.proginn.com'+'/?loginbox=show'
          return
        }
        $.ajax({
          type: 'POST',
          url: '/api/user/follow',
          dataType: "json",
          data:{
            // todo, 右边参数替换
            follow_id: "385691"
          },
          success(res) {
              console.log(res);
              if (res.data.follow_status){
                  //alert(res.data.follow_status);
                  $('#follow-btn a').addClass('btn-death');
                  $('#follow-btn a').text('已关注');
              }else {
                  $('#follow-btn a').removeClass('btn-death');
                  $('#follow-btn a').text('关注TA');
              }

          },
        })
      }
      function doLike(e) {

          if($('#isLogin')[0].dataset.value === '0') {
              location.href = 'https://www.proginn.com'+'/?loginbox=show'
              return
          }
        $.ajax({
          type: 'POST',
          url: '/api/user/like',
          dataType: "json",
          data: {
            // todo, 右边参数替换
            topic_id: '63638',
          },
          success(res) {

            console.log(res)
              if (res.data.like_status){
                  //alert(res.data.follow_status);
                  $('#good-btn').addClass('good-death');
                  $('#good-btn span').text(parseInt($('#good-btn span').text())+1);
              }else {
                  $('#good-btn').removeClass('good-death');
                  $('#good-btn span').text(parseInt($('#good-btn span').text())-1);
              }
          },
        })
      }
      $('#coner-radius').on('click', function() {
        // todo，id获取
        var id='385691';
        location.href = '/u/' + id
      })

      var toastMsg = function (msg, duration) {
	      var toast = $('<div class="modal toast">' + msg + '</div>')
	      $('body').append(toast)
	      $(toast).show()
	      $(toast).addClass('modal-in')
	      $(toast).on('tap', function () {
		      remove()
	      })

	      function remove() {
		      $(toast).removeClass('modal-in').addClass('modal-out')
		      setTimeout(function () {
			      $(toast).remove()
		      }, 400)
	      }

	      setTimeout(function () {
		      remove()
	      }, duration || 1500)
      }
    </script>



<script>
	var _hmt = _hmt || [];
	(function () {
		var hm = document.createElement("script");
		hm.src = "https://hm.baidu.com/hm.js?18455f493c982100e5a82ec978a8d06e";
		var s = document.getElementsByTagName("script")[0];
		s.parentNode.insertBefore(hm, s);
	})();
</script>
<script>
	(function () {
		var bp = document.createElement('script');
		var curProtocol = window.location.protocol.split(':')[0];
		if (curProtocol === 'https') {
			bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
		}
		else {
			bp.src = 'http://push.zhanzhang.baidu.com/push.js';
		}
		var s = document.getElementsByTagName("script")[0];
		s.parentNode.insertBefore(bp, s);
	})();
</script>


<a id="scrollUp" href="https://jishuin.proginn.com/p/763bfbd31896#top" style="position: fixed; z-index: 2147483647;">Scroll to top</a><textarea tabindex="-1" style="position: absolute; inset: -999px auto auto 0px; border: 0px; padding: 0px; box-sizing: content-box; overflow-wrap: break-word; overflow: hidden; transition: none 0s ease 0s; height: 0px !important; min-height: 0px !important; font-family: tahoma, Helvetica, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft Yahei&quot;, 微软雅黑, 宋体, sans-serif; font-size: 13px; font-weight: 400; font-style: normal; letter-spacing: 0px; text-transform: none; word-spacing: 0px; text-indent: 0px; line-height: 18.5714px; width: 709px;" class="autosizejs" id="autosizejs"></textarea><ins class="adsbygoogle adsbygoogle-noablate" data-adsbygoogle-status="done" style="display: none !important;" data-ad-status="unfilled"><ins id="aswift_0_expand" style="border: none; height: 0px; width: 0px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-table;" tabindex="0" title="Advertisement" aria-label="Advertisement"><ins id="aswift_0_anchor" style="border: none; height: 0px; width: 0px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: block;"><iframe id="aswift_0" name="aswift_0" style="left:0;position:absolute;top:0;border:0;width:undefinedpx;height:undefinedpx;" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" frameborder="0" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/ads.html" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" data-google-container-id="a!1" data-load-complete="true"></iframe></ins></ins></ins><iframe src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/aframe.html" width="0" height="0" style="display: none;"></iframe></body><iframe id="google_esf" name="google_esf" src="./老半天，终于把 redis 持久化搞懂了-技术圈_files/zrt_lookup.html" style="display: none;"></iframe></html>